# 代码验证脚本
Write-Host "🔍 验证HarmonyOS缓存插件代码..." -ForegroundColor Cyan

# 检查关键文件是否存在
$files = @(
    "entry/src/main/ets/pages/Index.ets",
    "localcache/Index.ets",
    "localcache/src/main/ets/cache/SimpleCacheManager.ets",
    "localcache/src/main/ets/cache/LocalCacheManager.ets"
)

Write-Host "\n📁 检查文件存在性:" -ForegroundColor Yellow
foreach ($file in $files) {
    if (Test-Path $file) {
        Write-Host "✅ $file" -ForegroundColor Green
    } else {
        Write-Host "❌ $file" -ForegroundColor Red
    }
}

# 检查导入配置
Write-Host "\n📦 检查模块导入配置:" -ForegroundColor Yellow
$indexContent = Get-Content "entry/src/main/ets/pages/Index.ets" -Raw
if ($indexContent -match "import.*SimpleCacheManager.*from.*localcache") {
    Write-Host "✅ entry模块正确导入localcache" -ForegroundColor Green
} else {
    Write-Host "❌ entry模块导入配置有问题" -ForegroundColor Red
}

# 检查导出配置
$localcacheContent = Get-Content "localcache/Index.ets" -Raw
if ($localcacheContent -match "export.*SimpleCacheManager") {
    Write-Host "✅ localcache模块正确导出SimpleCacheManager" -ForegroundColor Green
} else {
    Write-Host "❌ localcache模块导出配置有问题" -ForegroundColor Red
}

# 检查类型导入
if ($indexContent -match "import.*CacheStats.*from.*localcache") {
    Write-Host "✅ entry模块正确导入CacheStats类型" -ForegroundColor Green
} else {
    Write-Host "❌ entry模块缺少CacheStats类型导入" -ForegroundColor Red
}

# 检查any类型使用
if ($indexContent -match "\bas any\b") {
    Write-Host "❌ entry模块仍然使用any类型" -ForegroundColor Red
} else {
    Write-Host "✅ entry模块已移除any类型使用" -ForegroundColor Green
}

Write-Host "\n✨ 代码验证完成！" -ForegroundColor Cyan
Write-Host "📝 注意：由于构建工具不可用，这只是基本的文件和配置检查。" -ForegroundColor Yellow
Write-Host "🚀 建议在DevEco Studio中打开项目进行完整构建测试。" -ForegroundColor Yellow